package com.ctg.behavior.client.impala.utils;

import java.io.InputStream;
import java.util.List;

import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;

public class CtCalcResourceUtils {

	public static String loadClassPathResource(String jsonFileName) {
		ClassPathResource classPathResource = null;
		classPathResource = new ClassPathResource(jsonFileName);
		StringBuilder sbuilder = new StringBuilder();
		InputStream inputStream = null;
		try {
			inputStream = classPathResource.getInputStream();
			List<String> lines = IOUtils.readLines(inputStream, "UTF-8");
			for (String line : lines) {
				sbuilder.append(line);
			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (null != inputStream) {
					inputStream.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return sbuilder.toString();
	}

}
